package com.xipu.yygh.order.listener;

import com.rabbitmq.client.Channel;
import com.xipu.yygh.order.service.OrderInfoService;
import com.xipu.yygh.rabbit.constant.MqConst;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * description: 订单模板监听器
 * @author: gql
 * @date: 2022/05
 */
@Component
public class OrderListener {
    /**
     * 订单信息
     */
    @Autowired
    private OrderInfoService orderInfoService;

    /**
     * 监听到定时任务后,执行就医提醒方法
     * @param message 消息
     * @param channel 信道
     * @throws IOException
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_TASK_8, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_TASK),
            key = {MqConst.ROUTING_TASK_8}
    ))
    public void patientTips(Message message, Channel channel) throws IOException {
        this.orderInfoService.patientTips();
    }
}
